package org.example.leetcode;

/**
 * @outher 刘旭
 * @date 2024/6/21 14:35
 */
public class Topic303 {

    int[] sums;
    int[] nums;
    public Topic303(int[] nums) {
        this.nums = nums;
        sums = new int[nums.length];
        int m = 0;
        for (int i = 0; i < nums.length; i++) {
            m+=nums[i];
            sums[i]=m;
        }
    }
    public int sumRange(int left, int right) {
        return sums[right]-sums[left]+nums[left];
    }
}
